<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
		   <input type="hidden" id="telentsId" name="telentsId" value="${telentsId }"/> <!-- 简历id -->
			<fieldset>
				<legend>沟通记录</legend>
				<div class="form-group col-sm-11">
				<table class="table">
				  <thead>
				    <tr>
				      <th>序号</th>
				      <th>记录人</th>
				      <th>记录日期</th>
				      <th>沟通事项</th>
				      <th>沟通内容</th>
				    </tr>
				  </thead>
				  <tbody>
				  <c:forEach items="${chatlist }" var="chat" varStatus="num">
				  <tr <c:if test="${(num.count)%2==0 }">class="info"</c:if>>
				  <td>${num.count}</td>
				  <td>${chat.user.truename }</td>
				  <td>${chat.createDate.substring(0,19) }</td>
				  <td>${fns:getDictLabel(chat.classid,'resume_status','')}</td>
				  <td>${chat.details }</td>
				  </tr>
				  </c:forEach>
			 	<c:if test="${empty chatlist}">
			 	<tr class="danger"><td colspan="5" align="center">暂无沟通记录！</td></tr>
			 	</c:if>
				  </tbody>
				</table>
				</div>
			</fieldset>
			<fieldset>
				<legend>新增记录</legend>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通事项：</label>
				<div class="col-sm-8">
					<select class="form-control" name="classid">
						<c:forEach items="${fns:getDictList('resume_status')}"
							var="temp1">
							<option value="${temp1.value }">${temp1.valueName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="communicationTime" name="communicationTime" placeholder="请选择时间" readonly="readonly"/>
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">沟通详情：</label>
				<div class="col-sm-8">
					<textarea rows="3" cols="3" class="form-control" id="details" name="details" placeholder="请填写沟通详请"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">下次沟通：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="nextTime" name="nextTime" placeholder="请选择时间" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 备注 ：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="remark" name="remark"  value="${demandCommunicate.remark}"/>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
			</fieldset>
		</form>
	</div>


	<script>
	$(function () {
    	$('#communicationTime').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'day',
	        maxView:'decade',
	        language:  'zh-CN',
	        initialDate : new Date()
	  });
      $('#communicationTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
      $('#nextTime').datetimepicker({
          format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'day',
	        maxView:'decade',
	        language:  'zh-CN',
	        startDate: new Date()
	  });
      $('#nextTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
	  $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
           	  new Array('classid','事项分类未填写!'),
           	  new Array('details','沟通详情未填写!'),
           	  new Array('communicationTime','沟通时间未填写!'),
           	  new Array('nextTime','下次沟通未填写!')
        	)
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/demandCommunicate/update',
                type: 'post',
                dataType: "json",
                beforeSend: function () {
			        // 禁用按钮防止重复提交
					$("#sub").attr("disabled","disabled");
					swal("信息已经提交，请等待后台处理~！");
			    },
                success: function (data) {
                    if (data.code == 200) {
                    	swal({
							title : data.message,
							type : "success",
							showCancelButton : false,
							confirmButtonText : "确定",
							animation : "slide-from-bottom",
							text: "2秒后自动关闭。", 
	      	    			timer: 2000, 
							closeOnConfirm : true
						}, function() {
							top.Dialog.close();
						});
                    } else {
                        swal("错误", data.message, "error");
                    }
                }
            });

        });
    });
    
</script>
</body>
</html>